/*
 * ObjectElement.h
 *
 *  Created on: 2010-6-7
 *      Author: Guobc
 */

#ifndef OBJECTELEMENT_H_
#define OBJECTELEMENT_H_

#include "CommonElement.h"
#include "ParamElement.h"
#include "ASTNodeList.h"

namespace HA {
class ObjectElement: public HA::CommonElement {
public:
	ObjectElement();

	/**
	 * Get the set of names handles by this element.
	 * @return The names to be matched that create elements of this type.
	 */
	inline string* getIds() const {
		return mIds;
	}

	/**
	 * Get the set of names that cause this element to finish.
	 * @return The names of following elements that stop further parse.
	 */
	inline string* getEnds() const {
		return mEnds;
	}

	/**
	 * Allow creating an instance of this node.
	 * @return A new instance of this node.
	 */
	inline ASTNode* newInstance() const {
		return new ObjectElement();
	}

	/**
	 * Set new value of classid attribute.
	 * @param classId The new value of classid attribute.
	 */
	inline void setObjcetClssId(const string& classId) {
		setAttribute("CLASSID", classId);
	}

	/**
	 * Get value of classid attribute.
	 * @return The value of classid attribute.
	 */
	inline string getObectClassId() {
		return getAttribute("CLASSID");
	}

	/**
	 * Set new value of codebase attribute.
	 * @param codeBase The new value of codebase attribute.
	 */
	inline void setObjectCodeBase(const string& codeBase) {
		setAttribute("CODEBASE", codeBase);
	}

	/**
	 * Get value of codebase attribute.
	 * @return The value of codeBase attribute.
	 */
	inline string getObjectCodeBase() {
		return getAttribute("CODEBASE");
	}

	/**
	 * Set new value of codetype attribute.
	 * @param codeType The new value of codetype attribute.
	 */
	inline void setObjectCodeType(const string& codeType) {
		setAttribute("CODETYPE", codeType);
	}

	/**
	 * Get the value of codetype attribute.
	 * @return The value of codetype attribute.
	 */
	inline string getObjectCodeType() {
		return getAttribute("CODETYPE");
	}

	/**
	 * Set the new value of data attribute.
	 * @param newData The new value of data attribute.
	 */
	inline void setObjectData(const string& newData) {
		setAttribute("DADA", newData);
	}

	/**
	 * Get the value of data attribute.
	 * @return The value of data attribute.
	 */
	inline string getObjectData() {
		return getAttribute("DATA");
	}

	/**
	 * Get parameter elements in the children list of this element.
	 * @return The children of parameter element.
	 */
	ASTNodeList getParameters();

	/**
	 * Get parameter element with given param element's name attribute value.
	 * @param name The value of name attribute of param element.
	 */
	ParamElement* getParameter(const string& name);

	/**
	 * Add a paremeter element to this element.
	 * @param element The child of this element.
	 */
	inline void addParemeter(ParamElement* element) {
		appendChild(element);
	}

private:
	static string mIds[];
	static string mEnds[];
};
}

#endif /* OBJECTELEMENT_H_ */
